home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / Wood.0.72 / Sources / WoodDoc_OOE.m < prev    next >
Encoding:
Text File  |  1995-07-31  |  3.1 KB  |  167 lines

  1.  
  2. #import "wooddoc.h"
  3. #import "ScrollViewDeluxeForOOE.h"
  4.  
  5. @implementation WoodDoc (OOE_Server)
  6.  
  7. - connectToClient:client;
  8. {
  9.     id connectionToClient;
  10.     const char *path = NULL;
  11.     
  12.     isOOEServer = YES;
  13.     theOOEClient = client;
  14.     connectionToClient = [client connectionForProxy];
  15.     [connectionToClient registerForInvalidationNotification:self];
  16.     [client setProtocolForProxy:@protocol(OOE_ClientInterface)];
  17.     path = [client OOE_documentPath:self];
  18.     if(path)
  19.         theOOEClientPath = NXCopyStringBuffer(path);
  20.     [[scrollView theOOEButton] setEnabled:YES];    
  21.     return self;
  22. }
  23.  
  24. - senderIsInvalid:sender;
  25. {
  26.     theOOEClient = nil;
  27.     [[scrollView theOOEButton] setEnabled:NO];
  28.     return self;
  29. }
  30.  
  31. - (int)OOE_isDocEdited;
  32. {
  33.     return [window isDocEdited]; 
  34. }
  35.  
  36. - (int)OOE_orderDocumentFront:sender;
  37. {   
  38.     [NXApp activateSelf:YES];
  39.     [window makeKeyAndOrderFront:nil];
  40.     return 1;
  41. }
  42.  
  43. - (int)OOE_getSize:(NXSize *)aSize;
  44. {
  45.     NXRect aRect;
  46.     
  47.     [self calculateBoundingBox:&aRect];
  48.     NXInsetRect(&aRect, -5, -5);
  49.     *aSize = aRect.size;    
  50.     return 1;
  51. }
  52.  
  53. - calculateBoundingBox:(NXRect *)aRect;
  54. {
  55.     float lh,lw;
  56.     
  57.     [tree getTreeBounds:aRect lowerWidth:&lw lowerHeight:&lh];
  58.     return self;
  59. }
  60.  
  61. - (void)OOE_closeDocument:sender;
  62. {
  63.     isOOEServer = NO;
  64.     [self clean:self];
  65.     [self close:self];
  66.     return; 
  67. }
  68.  
  69. - (int)OOE_document:client savedAs:(const char *)path;
  70. {
  71.     if(theOOEClientPath != NULL) 
  72.         NX_FREE(theOOEClientPath);
  73.     if(path == NULL)
  74.         path = "UNTITLED";
  75.     theOOEClientPath = NXCopyStringBuffer(path);
  76.     return 1;
  77. }
  78.  
  79. - (int)OOE_provideData:sender;
  80. {
  81.     id pboard = nil;
  82.     
  83.     pboard = [Pasteboard newName:OOE_PASTEBOARD];
  84.     [self declareOOEPasteboard:pboard];
  85.     [self writeDataToPasteboard:pboard];
  86.     [self writePostScriptToPasteboard:pboard];
  87.     [window setDocEdited:NO];    
  88.     return 1;
  89. }
  90.  
  91. - orderClientDocumentFront:sender;
  92. {
  93.     [theOOEClient OOE_orderClientDocumentFront:self];
  94.     return self;
  95. }
  96.  
  97. - (BOOL)isOOEServer
  98. {
  99.     return isOOEServer;
  100. }
  101.  
  102. - setTitle_OOE:sender;
  103. {
  104.     char buf[MAXPATHLEN+1];
  105.     
  106.     if(theOOEClient == nil && isOOEServer)
  107.         strcpy(buf, "Embedded: **** DEAD EDITOR ****");    
  108.     else if(theOOEClientPath == NULL)
  109.         strcpy(buf, "Embedded: UNTITLED");    
  110.     else
  111.         sprintf(buf, "Embedded: %s", theOOEClientPath);
  112.     [[window contentView] ooeStatusChanged:self];    // OOE 2.0
  113.     [window setTitle:buf];
  114.     return self;
  115. }
  116.  
  117. - docWillClose_OOE:sender;
  118. {
  119.     if(theOOEClient == nil) 
  120.         return self;
  121.     if(!isOOEServer) 
  122.         return self;
  123.     [[theOOEClient connectionForProxy] 
  124.         unregisterForInvalidationNotification:self];
  125.     NX_DURING
  126.         [theOOEClient OOE_documentWillClose:self];    
  127.     NX_HANDLER
  128.         NXLogError("DOC %s, OOE: Error %d for "
  129.                 "'OOE_documentWillClose:'",
  130.                 [self name],
  131.                 NXLocalHandler.code);
  132.     NX_ENDHANDLER
  133.     [NXConnection removeObject:self];
  134.     return self;
  135. }
  136.  
  137. - free_OOE;
  138. {
  139.     NX_DURING
  140.         //[theOOEClient free];    // 940824
  141.                         // causes timeout
  142.                         // why?
  143.         theOOEClient = nil;    
  144.     NX_HANDLER
  145.             NXLogError("ERROR, DOC, OOE: Error %d when "
  146.                     "freeing theOOEClient.",
  147.                     NXLocalHandler.code);
  148.             
  149.     NX_ENDHANDLER
  150.     if(theOOEClientPath != NULL) {
  151.         NX_FREE(theOOEClientPath);
  152.         theOOEClientPath=NULL;
  153.     }
  154.     return self;
  155. }
  156.  
  157. - updateOOETarget:sender;
  158. {
  159.     [theOOEClient OOE_documentWasChanged:self];
  160.     [theOOEClient OOE_orderClientDocumentFront:self];
  161.     return self;
  162. }
  163.  
  164. @end
  165.  
  166.  
  167.